package com.yuanfuxing.boxuegu.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yuanfuxing.boxuegu.R;
import com.yuanfuxing.boxuegu.fragment.CourseFragment;
import com.yuanfuxing.boxuegu.fragment.ExerciseFragment;
import com.yuanfuxing.boxuegu.fragment.MyFragment;


public class MainActivity extends AppCompatActivity {
    FragmentManager fragmentManager;
    FragmentTransaction fragmentTransaction;
    private View mCourseBtn;
    private View mExercisesBtn;
    private View mMyInfoBtn;
    private TextView tv_course;
    private TextView tv_exercises;
    private TextView tv_myInfo;
    private ImageView iv_course;
    private ImageView iv_exercises;
    private ImageView iv_myInfo;
    private TextView tv_back;
    private TextView tv_main_title;
    private RelativeLayout rl_title_bar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        iv_course = (ImageView) findViewById(R.id.main_bottom_bar_image_course);
        iv_exercises = (ImageView) findViewById(R.id.main_bottom_bar_image_exercises);
        iv_myInfo = (ImageView) findViewById(R.id.main_bottom_bar_image_myinfo);
        tv_course = (TextView) findViewById(R.id.main_bottom_bar_text_course);
        tv_exercises = (TextView) findViewById(R.id.main_bottom_bar_text_exercises);
        tv_myInfo = (TextView) findViewById(R.id.main_bottom_bar_text_myinfo);

        fragmentManager = getFragmentManager();
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.main_body,new CourseFragment());
        fragmentTransaction.commit();

        iv_course.setImageResource(R.drawable.main_course_icon);
        iv_exercises.setImageResource(R.drawable.main_exercises_icon);
        iv_myInfo.setImageResource(R.drawable.main_my_icon);
        tv_course.setTextColor(Color.parseColor("#ACCCF4"));
        tv_exercises.setTextColor(Color.parseColor("#9C9C9C"));
        tv_myInfo.setTextColor(Color.parseColor("#9C9C9C"));

    }
    public void exercise(View view){
        iv_course.setImageResource(R.drawable.main_course_icon);
        iv_exercises.setImageResource(R.drawable.main_exercises_icon_selected);
        iv_myInfo.setImageResource(R.drawable.main_my_icon);
        tv_course.setTextColor(Color.parseColor("#ACCCF4"));
        tv_exercises.setTextColor(Color.parseColor("#9C9C9C"));
        tv_myInfo.setTextColor(Color.parseColor("#9C9C9C"));

        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.main_body,new ExerciseFragment());
        fragmentTransaction.commit();
    }
    public void course(View view){
        iv_course.setImageResource(R.drawable.main_course_icon_selected);
        iv_exercises.setImageResource(R.drawable.main_exercises_icon);
        iv_myInfo.setImageResource(R.drawable.main_my_icon);
        tv_course.setTextColor(Color.parseColor("#ACCCF4"));
        tv_exercises.setTextColor(Color.parseColor("#9C9C9C"));
        tv_myInfo.setTextColor(Color.parseColor("#9C9C9C"));

        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.main_body,new CourseFragment());
        fragmentTransaction.commit();
    }
    public void my(View view){
        iv_course.setImageResource(R.drawable.main_course_icon);
        iv_exercises.setImageResource(R.drawable.main_exercises_icon);
        iv_myInfo.setImageResource(R.drawable.main_my_icon_selected);
        tv_course.setTextColor(Color.parseColor("#ACCCF4"));
        tv_exercises.setTextColor(Color.parseColor("#9C9C9C"));
        tv_myInfo.setTextColor(Color.parseColor("#9C9C9C"));

        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.main_body,new MyFragment());
        fragmentTransaction.commit();
    }
}
